
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 1649. -- [Usaco2006 Dec]Cow Roller Coaster -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>1649: [Usaco2006 Dec]Cow Roller Coaster</h2><span class=green>Time Limit: </span>5 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>64 MB<br><span class=green>Submit: </span>152&nbsp;&nbsp;<span class=green>Solved: </span>87<br>[<a href='submitpage.php?id=1649'>Submit</a>][<a href='problemstatus.php?id=1649'>Status</a>][<a href='bbs.php?id=1649'>Discuss</a>]</center><h2>Description</h2><div class=content>The cows are building a roller coaster! They want your help to
design as fun a roller coaster as possible, while keeping to the
budget.

The roller coaster will be built on a long linear stretch of land
of length L (1 <= L <= 1,000). The roller coaster comprises a
collection of some of the N (1 <= N <= 10,000) different interchangable
components. Each component i has a fixed length Wi (1 <= Wi <= L).
Due to varying terrain, each component i can be only built starting
at location Xi (0 <= Xi <= L-Wi). The cows want to string together
various roller coaster components starting at 0 and ending at L so
that the end of each component (except the last) is the start of
the next component.

Each component i has a "fun rating" Fi (1 <= Fi <= 1,000,000) and
a cost Ci (1 <= Ci <= 1000). The total fun of the roller coster is
the sum of the fun from each component used; the total cost is
likewise the sum of the costs of each component used. The cows'
total budget is B (1 <= B <= 1000). Help the cows determine the
most fun roller coaster that they can build with their budget.

有n个区间，长度为Wi，起点为Xi，终点为Xi + Wi，每个区间有一个权值Fi，和一个费用Ci。现在奶牛们要买一些区间，使他们首尾相连，并且第一个区间的起点为0，最后一个区间终点为L，并且他们权值最大。奶牛只有B元钱。</div><h2>Input</h2><div class=content>* Line 1: Three space-separated integers: L, N and B.

* Lines 2..N+1: Line i+1 contains four space-separated integers,
        respectively: Xi, Wi, Fi, and Ci.

</div><h2>Output</h2><div class=content>* Line 1: A single integer that is the maximum fun value that a
        roller-coaster can have while staying within the budget and
        meeting all the other constraints. If it is not possible to
        build a roller-coaster within budget, output -1.

</div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>5 6 10<br />
0 2 20 6<br />
2 3 5 6<br />
0 1 2 1<br />
1 1 1 3<br />
1 2 5 4<br />
3 2 10 2<br />
<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>17<br />
<br />
OUTPUT DETAILS:<br />
<br />
Taking the 3rd, 5th and 6th components gives a connected roller-coaster<br />
with fun value 17 and cost 7. Taking the first two components would<br />
give a more fun roller-coaster (25) but would be over budget.<br />
<br />
</span></div><h2>HINT</h2>
			<div class=content><p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Silver'>Silver</a></p></div><center>[<a href='submitpage.php?id=1649'>Submit</a>][<a href='problemstatus.php?id=1649'>Status</a>][<a href='bbs.php?id=1649'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
